<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <h1>简单计算器</h1>
    <input type="text" v-model.number='num1'> + <input type="text" v-model.number='num2'> = <span>{{sum}}</span>
  </div>
  <script type="text/javascript" src="js/vue.js"></script>
  <script type="text/javascript">
    /*
      要求: 实时计算两数之和
    */
    var vm = new Vue({
      el: '#app',
      data: {
        num1:'',
        num2:'',
        sum:0
      },
      methods: {

      },
      watch:{
        num1:function(){
           this.sum = this.num1 + this.num2
        },
        num2:function(){
           this.sum = this.num1 + this.num2
        }
      }
    });
  </script>
</body>
</html>
